#include"head.h"
void *func(void*arg){
    ShareValue*sv=(ShareValue*)arg;
    while(1){
        pthread_mutex_lock(&sv->lock_mutex);
        while(sv->q.size<=0&&sv->exit_flag==0){
            pthread_cond_wait(&(sv->cond),&(sv->lock_mutex));
        }
        if(sv->exit_flag==1){
            pthread_mutex_unlock(&sv->lock_mutex);
            pthread_exit(0);
        }
        transport_protocol_t msg;
        int client_fd=enqueue(&(sv->q),&msg);
        pthread_mutex_unlock(&sv->lock_mutex);
        if(client_fd>0){
            dowork(client_fd,msg);
            close(client_fd);
        }
    }
}
